<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	    <base href="<%=basePath%>">
	    <title>${title}</title>
		<script type="text/javascript" src="<c:url value='/resource/js/jquery-1.7.2.min.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/artdialog/artdialog.js?skin=${sys_theme}'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/artdialog/iframetools.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/js/common.js'/>"></script>	
		<script type="text/javascript">
			$(function(){
				//关闭窗口
				$("#btn_esc,#btn_esc1").click(function(){
					art.dialog.close();
				});
				//更新用户密码
				$("#btn_submit").click(function(){
					var _flag = checkForm();
					if(_flag){
						$.ajax({
							url:"<c:url value='/profile/verify.json'/>",
							data:{password:$("#password").val().replace(/(^\s*)|(\s*$)/,""),newPassword:$("#new_password").val().replace(/(^\s*)|(\s*$)/,""),password_2:$("#new_password_2").val().replace(/(^\s*)|(\s*$)/,"")},
							type:"post",
							dataType:"text",
							success:function(data){
								var _data = eval("("+data+")");
								if(_data.msg){
									art.dialog.tips(_data.msg.body);
								}
							}
						});
					}
				});
				
				//更新用户个人信息
				$("#btn_submit_1").click(function(){
					var reg = /^(13[0-9]|15[0-35-9]|18[0236789]|14[57])[0-9]{8}$/;
					if($("#tel_mobile").val().length!=0&&!reg.test($("#tel_mobile").val())){
						art.dialog.tips("请输入正确的移动电话号码!");
						$("#tel_mobile").focus();
						return false;
					}
					if(isEmpty("#tel_mobile","请输入移动电话号码！")){
						$.ajax({
							url:"<c:url value='/profile/change.json'/>",
							data:{
								tel_inter:$("#tel_inter").val(),
								tel_outside:$("#tel_outside").val(),
								tel_short:$("#tel_short").val(),
								tel_mobile:$("#tel_mobile").val(),
								tel_office:$("#tel_office").val(),
								tel_home:$("#tel_home").val()
							},
							type:"post",
							dataType:"text",
							success:function(data){
								var _data = eval("("+data+")");
								if(_data.msg){
									art.dialog.tips(_data.msg.body);
									window.setTimeout(function(){
										art.dialog.close();
									},1500);
								}
							}
						});
					}
				});
				
				//修改密码
				$("#p_pwd").click(function(){
					$(this).css({"background-color":"#69A5EE","font-weight":"bold"});
					$("#p_tel").css({"background-color":"#fff","font-weight":"normal"});
					$("#profile1").css({"display":"block"});
					$("#profile2").css({"display":"none"});
				});
				//
				$("#p_tel").click(function(){
					$(this).css({"background-color":"#69A5EE","font-weight":"bold"});
					$("#p_pwd").css({"background-color":"#fff","font-weight":"normal"});
					$("#profile1").css({"display":"none"});
					$("#profile2").css({"display":"block"});
				});
			});
			
			function checkEqual(){
				if($("#new_password").val().replace(/(^\s*)|(\s*$)/g, "") != $("#new_password_2").val().replace(/(^\s*)|(\s*$)/g, "")){
					art.dialog.tips("前后两次输入的密码不一致！");
					$("#new_password_2").focus();
					$("#new_password_2").select();
					return false;
				}
				return true;
			}
			//决断是否为空
			function isEmpty(id,msg){
				if("" == $(id).val().replace(/(^\s*)|(\s*$)/g,"")){
					art.dialog.tips(msg);
					$(id).focus();
					$(id).select();
					return false;
				}
				return true;
			}
			//检查表单
			function checkForm(){
				return isEmpty("#password","请输入原始密码！")&&
				isEmpty("#new_password","请输入新密码！")&&
				isEmpty("#new_password_2","请输入确认密码！")&&
				checkEqual();
			}
		</script>
		<style type="text/css">
			body{margin:0 auto;font-size:12px;color:#535353;font-family:verdana 黑体;}
			a{text-decoration:none;}
			#container{width:440px;height:190px;padding:0px;margin:0px;}
			#container td{padding:0px;margin:0px;height:25px;}
			table{margin-bottom:5px;}
			#profile1 input{font-family:verdana 黑体;border:1px solid #ccc;}
			#profile1,#profile2{padding:0px;margin:0px;}
			#profile1 fieldset,#profile2 fieldset{padding:0px;margin:5px;margin-top:0px;}
			#profile0 p{float:left;padding:3px 5px 3px 5px;border:1px solid #ccc;margin-top:2px; border-left:none;cursor:pointer;}
			#p_tel{background-color:#69A5EE;font-weight:bold;}
			#password,#new_password,#new_password_2{width:345px;height:20px;line-height:20px;font-size:14px;font-weight:bold;font-family:verdana 黑体;}
			#tel_office,#tel_mobile,#tel_home,#tel_inter,#tel_outside,#tel_short{width:140px;height:20px;line-height:20px;font-size:14px;font-weight:bold;font-family:verdana 黑体;}
			.td_title{text-align:right;width:55px;height:30px;line-height:30px;}
			#btn_submit,#btn_submit_1,#btn_esc,#btn_esc1{height:26px;line-height:26px;width:74px;margin:0px;padding:0px;border:0;background:url(resource/images/ga_btn.gif) left top no-repeat; margin-right:10px;color:#535353;cursor:pointer;}
			#btn_submit:hover,#btn_submit_1:hover,#btn_esc:hover,#btn_esc1:hover{background:url(resource/images/ga_btn_a.gif) left top no-repeat;color:#1f2b62;}
		</style>
	</head>
	<body >
		<div id="container">
			<div id="profile0">
				<p id="p_tel">联系方式</p>
				<p id="p_pwd">修改密码</p>
			</div>
			<div style="clear:both;"></div>
			<div id="profile1" style="display:none;">
				<fieldset style="margin-top:10px;">
					<legend>修改密码</legend>
					<table>
							<tr>
								<td class="td_title">原始密码:</td>
								<td><input id="password" type="password" maxlength="15" name="password" onblur="this.value=this.value.replace(/[^\w\b]/g,'');"/><span style="color:red;">*</span></td>
							</tr>
							<tr>
								<td class="td_title">新   密   码:</td>
								<td><input id="new_password" type="password" maxlength="15"  name="newPassword" onblur="this.value=this.value.replace(/[^\w\b]/g,'');"/><span style="color:red;">*</span></td>
							</tr>
							<tr>
								<td class="td_title">确认密码:</td>
								<td><input id="new_password_2" type="password" maxlength="15"  name="password_2" onblur="this.value=this.value.replace(/[^\w\b]/g,'');"/><span style="color:red;">*</span></td>
							</tr>
					</table>
				</fieldset>
				<div style="text-align:right;margin-top:10px;margin-bottom:10px;">
					<input id="btn_submit" type="button" value="保存" style="margin-right:10px;"/>
					<input id="btn_esc"  type="button" value="关闭" style="margin-right:0px;"/>
				</div>
			</div>
			<div id="profile2">
				<fieldset style="margin-top:10px;">
					<legend>联系方式</legend>
					<table>
						<tr>
							<td class="td_title">内线:</td>
							<td><input type="text" id="tel_inter" value="${user.tel_inter}" onblur="this.value=this.value.replace(/\s/g,'');" maxlength="13"/></td>
							<td class="td_title">办公电话:</td>
							<td><input type="text" id="tel_office" value="${user.tel_office}" onblur="this.value=this.value.replace(/[^0-9\-]/g,'');" maxlength="13"/></td>
						</tr>
						<tr>
							<td class="td_title">短号:</td>
							<td><input type="text" id="tel_short" value="${user.tel_short}" onblur="this.value=this.value.replace(/[^0-9\-]/g,'');" maxlength="13"/></td>
							<td class="td_title">移动电话:</td>
							<td ><input type="text" id="tel_mobile" value="${user.tel_mobile}" onblur="this.value=this.value.replace(/[^0-9\-]/g,'');" maxlength="13"/>
								<span style="color:red">*</span>
							</td>
						</tr>
						<tr>
							<td class="td_title">外线:</td>
							<td><input type="text" id="tel_outside" value="${user.tel_outside}" onblur="this.value=this.value.replace(/[^\,\，\-\d]/g,'');" maxlength="13"/></td>
							<td class="td_title">家庭电话:</td>
							<td><input type="text" id="tel_home" value="${user.tel_home}" onblur="this.value=this.value.replace(/[^0-9\-]/g,'');" maxlength="13"/></td>
						</tr>
					</table>
				</fieldset>
				<div style="text-align:right;margin-top:10px;margin-bottom:10px;">
					<input id="btn_submit_1" class="mac_btn" type="button" value="保存" style="margin-right:10px;"/>
					<input id="btn_esc1"  class="mac_btn" type="button" value="关闭" style="margin-right:0px;"/>
				</div>
			</div>
		</div>
	</body>
</html>
